import $ from "jquery";
import style from "./index.module.less";

let container;
function init() {
  container = $("<div>").addClass(style.container).appendTo("#app");
}
init();

// cover: "https://img1.doubanio.com/view/photo/s_ratio_poster/public/p2635669599.jpg"
// rate: 6.1
// title: "兴安岭猎人传说"
// url: "https://movie.douban.com/subject/35027719/"
// _id: "6095093b1aaaea32a05cceed"
export function createMoviePage(movies) {
  //    movies.forEach(element => {
  //     console.log(element.title);
  //     $('<img>').prop('src',element.cover).addClass(style.cover).appendTo(container);
  //    });
  const result = movies
    .map((item) => {
      return `<div>
    <a href="${item.url}" target="_blank"><img  src="${item.cover}" ></a>
    <p class='${style.title}'>${item.title}</p>
    <p class='${style.rate}'>${item.rate}</p>
  </div>`;
    })
    .join("");
  container.html(result);
}
